<tc_include file="Public:head"/>
<body ontouchstart style="background: #3c3c3c;">
<div class="container" id="container">
    <div class="page">
        <div class="page__bd" style="height: 100%; overflow: hidden;">
            <div class="weui-tab">
                <div class="weui-tab__panel">
                    <div class="login-box">
                        <div class="text-center">
                            <div class="weui-grid__icon">
                                <img src="__TMPL__Public/assets/images/head-portrait.jpg" alt="">
                            </div>
                        </div>
                        <div class="weui-cells weui-cells_form">
                            <div class="weui-cell">
                                <div class="weui-cell__hd">
                                    <i class="icon iconfont icon-phone"></i>
                                </div>
                                <div class="weui-cell__bd">
                                    <input id="mobile" class="weui-input" type="tel" placeholder="请输入手机号">
                                </div>
                            </div>
                            <div class="weui-cell" style="position: relative;">
                                <div class="weui-cell__hd">
                                    <i class="icon iconfont icon-password"></i>
                                </div>
                                <div class="weui-cell__bd">
                                    <input id="password" class="weui-input" type="password" style="width: 65%" placeholder="密码">
                                </div>
                                <div class="weui-cell__ft" style="position: absolute;right:15px;font-size: 14px;">
                                <a href="{:U('forget/index')}" class="linkgay">? 忘记密码</a>
                                </div>
                            </div>
                        </div>
                        <div class="weui-cells__tips text-center" style="padding-top: 10px;">
                            <a href="{:U('Public/quickLogin')}" class="linkgay">短信快捷登录</a></div>
                        <div class="weui-btn-area">
                            <a class="weui-btn weui-btn_default weui-btn_login" href="javascript:"
                               id="btn_login">会员登陆<br/><span>Member Login</span></a>
                            <a class="weui-btn weui-btn_default weui-btn_reg" href="{:U('public/register')}"
                               id="btn_register">注册会员<br/><span>sign up</span></a>
                        </div>
                        <div class="weui-cells__tips text-center quick-login-title"><span class="linkgay">快速登陆</span>
                        </div>
                        <div class="weui-cells__tips text-center">
                            <a href="{:U('/Wx/Wxauth/Index',array('action'=>'login'))}" class="weixin-box">
                                <i class="icon iconfont icon-weixin"></i>
                            </a>
                        </div>
                    </div>
                </div>
                <tc_include file="Public:menu"/>
            </div>
        </div>
    </div>
</div>
<div id="dialogs">
    <!--BEGIN regDialog-->
    <div class="js_dialog" id="errDialog" style="display: none;">
        <div class="weui-mask"></div>
        <div class="weui-dialog notice-dialog">
            <div class="weui-dialog__btn">&times;</div>
            <div class="icon-box">
                <i class="icon iconfont icon-notice"></i>
            </div>
            <div class="weui-dialog__bd">
                <div class="weui-dialog__title">注册成功！</div>
                <p>欢迎加入夏都小镇，<font>即将跳转会员页面！</font></p>
            </div>
        </div>
    </div>
    <!--END regDialog-->
</div>
<tc_include file="Public:footer"/>

<script type="text/javascript">

    function show_dialog(code, title, content) {
        if (code == 200) {
            $(".weui-dialog__bd .weui-dialog__title").html("登录成功！");
            $(".weui-dialog__bd p").html("欢迎登录夏都小镇，<font>即将跳转会员页面！</font>");
        }
        else {
            $(".weui-dialog__bd .weui-dialog__title").html(title);
            $(".weui-dialog__bd p").html(content);
        }
        $('#errDialog').fadeIn(0);
    }

    //关闭dialogs
    $('#dialogs').on('click', '.weui-dialog__btn', function () {
        $(this).parents('.js_dialog').fadeOut(0);
    });


    $("#btn_login").click(function () {
        var mobile = $('#mobile').val();
        var password = $("#password").val();

        var isMobile = /^(1+\d{10})$/;
        var isPassword = /^[0-9a-zA-Z_]{6,15}$/;
        if(!isMobile.exec(mobile)){
            show_dialog(0,'登录失败！','请输入正确的手机号');
            return false;
        }
        if(!isPassword.exec(password)){
            show_dialog(0,'登录失败！','请输入6位以上数字及密码');
            return false;
        }

        $.post("{:U('public/dologin')}", {mobile: mobile, password: password}, function (data) {
            if (data.code == 200) {
                show_dialog(200);
                setTimeout(function(){
                    location.href = "{$url}";
                }, 1000);
            }
            else {
                show_dialog(data.code, '登录失败！', data.message);
            }
        });

    });


</script>